<template>
	<div class="city">
		<city-header></city-header>
		<city-search :cities="cities"></city-search>
		<city-list 
		:cities="cities" 
		:hotCities="hotCities"
		:alpha="alpha"
		></city-list>
		<city-alphabet 
		:cities="cities"
		@change="alphaChange"
		></city-alphabet>
	</div>
</template>

<script>
import axios from 'axios'
import CityHeader from './components/header'
import CitySearch from './components/Search'
import CityList from './components/citylist'
import CityAlphabet from './components/Alphabet'
export default {
	name:'City',
	components:{
		CityHeader,
		CitySearch,
		CityList,
		CityAlphabet
	},
	data () {
		return {
			hotCities:[],
			cities:{},
			alpha:''
		}
	},
	methods :{
		getCityInfo () {
			axios.get('/api/city.json').then(this.getCityInfoSucc)
		},
		getCityInfoSucc (res) {
			res = res.data
			if(res.ret && res.data){
				const data = res.data
				this.hotCities = data.hotCities
				this.cities = data.cities
			}
		},
		alphaChange (alpha) {
			this.alpha = alpha
		}
	},
	mounted () {
		this.getCityInfo()
	}
}
</script>

<style lang="stylus" scoped>
	
</style>
